package game.logic;
import tools.Point;
import game.Game;
import game.objects.GameObject;
public abstract class TimeActive extends GameObject {
	protected float lifetime;
	private float starttimer;
	public TimeActive(Game g, Point pos, float angle, float lifetime) {
		super(g, pos, angle);
		this.lifetime = lifetime;
	}
	public boolean isAlive() {
		if (lifetime == -1)
			return true;
		if (game.time - starttimer > lifetime)
			return false;
		return true;
	}
	public float getLifetime() {
		if (lifetime == -1)
			return 1;
		return 1 - ((game.time - starttimer) / lifetime);
	}
	public float getAbsolutLifetime(){
		return game.time-starttimer;
	}
	public void initialize(Point pos, float angle) {
		this.starttimer = game.time;
	}
}
